<!DOCTYPE html>
<html lang="zh">
<head>

    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>页面</title>
    <script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/loading.js"></script>
    <link href="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/theme-chalk/index.css" rel="stylesheet">
</head>
<style>
    .avatar-uploader .el-upload {
        border: 1px dashed #d9d9d9;
        border-radius: 6px;
        cursor: pointer;
        position: relative;
        overflow: hidden;
    }

    .avatar-uploader .el-upload:hover {
        border-color: #409EFF;
    }

    .avatar-uploader-icon {
        font-size: 28px;
        color: #8c939d;
        width: 178px;
        height: 178px;
        line-height: 178px;
        text-align: center;
    }

    .avatar {
        width: 178px;
        height: 178px;
        display: block;
    }
    .spacing{
        height: 50px;
    }
</style>

<body>
<div id="app">
    <el-container >
        <el-main>
        <el-header>
            <el-breadcrumb separator-class="el-icon-arrow-right">
                <el-breadcrumb-item :to="{ path: '/' }">订单管理</el-breadcrumb-item>
                <el-breadcrumb-item>收货单列表</el-breadcrumb-item>
            </el-breadcrumb>
        </el-header>

            <el-row :gutter="20" >
                <el-col :xs="6" :sm="6" :md="4" :lg="3" :xl="3">
                    <el-input placeholder="请输入收货单号" v-model="sales_order_no">
                    </el-input>
                </el-col>
                <el-col :xs="6" :sm="6" :md="4" :lg="3" :xl="3">
                    <el-input placeholder="请输入发货员" v-model="sales_man">
                    </el-input>
                </el-col>
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-input placeholder="请输入项目名称" v-model="project_name">
                    </el-input>
                </el-col>
                <el-col :xs="6" :sm="6" :md="4" :lg="3" :xl="3">
                    <el-date-picker
                            v-model="startTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="开始日期" style="width: 100%">
                    </el-date-picker>
                </el-col>
                <el-col :xs="8" :sm="8" :md="4" :lg="3" :xl="3" class="spacing">
                    <el-date-picker
                            v-model="endTime"
                            type="date"
                            value-format="yyyy-MM-dd"
                            placeholder="结束日期" style="width: 100%">
                    </el-date-picker>
                </el-col>
                <el-col :xs="6" :sm="6" :md="4" :lg="3" :xl="3">
                    <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
                </el-col>
            </el-row>

            <el-table :data="tableData" stripe border style="width:100%" highlight-current-row size="mini" tooltip-effect="dark" v-loading="tableLoading" height="calc(100vh - 240px)">

                　　<el-table-column label="序号" align="center" width="50px">
                <template scope="scope"><span>{{scope.$index+(currentPage - 1) * pageSize + 1}}</span></template>
            </el-table-column>
                <el-table-column prop="orderBill_id" label="收货单号" align="center" :show-overflow-tooltip=true >
                    　　 <template slot-scope="{row}">
                    {{ row.orderBill_id || '暂无' }}
                </template>
                </el-table-column>
                　　
                <#--<el-table-column prop="order_name" label="收货单名称" align="center">-->
                    <#--　　-->
                <#--</el-table-column>-->
                <el-table-column prop="surface_id" label="发货单号" align="center" :show-overflow-tooltip=true >
                    　　
                </el-table-column>
                <el-table-column prop="supply_user" label="发货员" align="center" :show-overflow-tooltip=true >
                    　　
                </el-table-column>
                <el-table-column prop="crtTime" label="现场收货时间" align="center" :show-overflow-tooltip=true>
                    　　 <template slot-scope="{row}">
                    {{ row.crtTime || '暂无' }}
                </template>
                </el-table-column>
                <el-table-column prop="project_name" label="项目名称" align="center" :show-overflow-tooltip=true>
                    　　 <template slot-scope="{row}">
                    {{ row.project_name || '暂无' }}
                </template>
                </el-table-column>
                <#--<el-table-column prop="crtTime" label="确认收货时间" align="center" :show-overflow-tooltip=true>-->
                    <#--　　 <template slot-scope="{row}">-->
                    <#--{{ row.crtTime || '暂无' }}-->
                <#--</template>-->
                </el-table-column>
                <el-table-column prop="price" label="收货金额" align="center" :show-overflow-tooltip=true>
                    　　 <template slot-scope="{row}">
                    {{ row.price || '暂无' }}
                </template>
                </el-table-column>
                <el-table-column prop="consignee_name" label="收货人" align="center" :show-overflow-tooltip=true>
                    　　 <template slot-scope="{row}">
                    {{ row.consignee_name || '暂无' }}
                </template>
                </el-table-column>
                　　
                <#--<el-table-column v-if prop="consignee_address" label="收货地址" align="center" :show-overflow-tooltip=true>-->
                    <#--　　 <template slot-scope="{row}">-->
                    <#--{{ row.consignee_address || '暂无' }}-->
                <#--</template>-->
                </el-table-column>
                <el-table-column prop="remark" label="备注" align="center" :show-overflow-tooltip=true>
                    　　 <template slot-scope="{row}">
                    {{ row.remark || '暂无' }}
                </template>
                </el-table-column>
                　<el-table-column prop="orderBill_customStat" label="状态" align="center" :formatter="formatStatus" :show-overflow-tooltip=true>
                　　</el-table-column>
                <el-table-column label="操作" align="center" min-width="100" fixed="right">
                    <template slot-scope="scope">
                    <#--等待乙方确认状态-->
                        <el-button type="text" v-if="scope.row.orderBill_customStat==1000"
                                   @click="detail(scope.row.orderBill_id,scope.row.orderBill_customStat)">查看
                        </el-button>
                         <#if success="fail">
                         <el-button type="text" v-if="scope.row.orderBill_customStat==1000"
                                    @click="edit(scope.row.orderBill_id)">编辑
                         </el-button>
                        <#--<el-button type="text" v-if="scope.row.orderBill_customStat==1000"-->
                                   <#--@click="revoke(scope.row.orderBill_id,scope.row.surface_id,scope.row.orderBill_customStat)">撤回-->
                        <#--</el-button>-->
                         </#if>
                        <#if success="success">
                        <el-button type="text" v-if="scope.row.orderBill_customStat==1000"
                                   @click="affirm(scope.row.orderBill_id,scope.row.orderBill_flow,scope.row.orderBean_pk)">确认
                        </el-button>
                        </#if>
                        <el-button type="text" v-if="scope.row.orderBill_customStat==1008"
                                   @click="detail(scope.row.orderBill_id,scope.row.orderBill_customStat)">查看
                        </el-button>
                    </template>
                </el-table-column>
            </el-table>
        </el-main>
        <el-footer>
            <el-row >
                <el-col >
                    <el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
                                   :page-sizes="[100, 500, 1000]" :page-size="pageSize"
                                   layout="total, sizes, prev, pager, next, jumper"
                                   :total="totalRecords" >
                    </el-pagination>
                </el-col>
            </el-row>
        </el-footer>
    </el-container>
</div>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/dist/vue.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/vue-element/lib/index.js"></script>
<script src="https://pinzafile.oss-cn-shanghai.aliyuncs.com/publiccss/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script>
    new Vue({
        el: '#app',
        data() {
            return {
                tableLoading:false,
                dialogFormVisible: false,
                dialogVisible: false,
                project_name:'',
                dialogImageUrl: '',
                sales_order_no: '',
                sales_order_name: '',
                sales_amount: '',
                tableData: [],
                currentPage: 1, //当前页
                pageSize: 100, //每页总数
                totalRecords: 0, //总条数
                sales_order_no: '',
                sales_man: "",
                file: '',
                param: '',
                startTime: '',
                endTime: '',
            };
            show: false

        },

        methods: {
            //状态转换
            formatStatus: function (row, column) {
                return row.orderBill_customStat == 1000 ? '待确认' : row.orderBill_customStat ==
                1008 ? '已确认' : '未知';
            },
            revoke(orderBill_id,surface_id){
                this.$confirm('确认撤回?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    this.tableLoading = true;
                    //声明要发送的参数
                    $.ajax({
                        url: '/order/revokeConsignee.json',
                        type: 'POST',
                        data: {surface_id:surface_id,orderBill_id:orderBill_id},
                        // contentType: "application/json",
                        // async: false,
                        dataType: 'json',
                        success: (result) =>{
                            this.tableLoading = false;
                            if (result.ret) {
                                this.$message({
                                    type: 'success',
                                    message: '操作成功',
                                });
                                this.ajaxFunction(null, null, null, null, null,null);
                            } else {
                            }
                        }
                    });

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消操作'
                    });
                });
            },
            search() {
                //声明要发送的参数
                this.currentPage=1;
                this.pageSize=100;
                this.ajaxFunction();
            },

            //收货单确认收货
            detail(val,customStat) {
                window.location.href = "/order/billPage.page?type=consignee&orderNo=" + val+"&customStat="+ customStat;
            },
            //收货单确认收货
            edit(val) {
                window.location.href = "/order/editConsignee.page?orderBill_id=" + val;
            },
            affirm(orderBill_id,orderBill_flow,orderBean_pk,project_name){
                var formData={};
                formData.orderBill_id=orderBill_id;
                formData.orderBill_flow=orderBill_flow;
                formData.orderBean_pk = orderBean_pk;
                formData.orderBill_customStat = "1008";
                formData.type = "consignee";
                var data = JSON.stringify(formData);
                $.ajax({
                    url: '/order/updateDispatch.json',
                    type: 'POST',
                    data: {formData:data},
                    // contentType: "application/json",
                    // async: false,
                    dataType: 'json',
                    success: (result) =>{
                        console.log(result);
                        if (result.ret) {
                            this.$message({
                                type: 'success',
                                message: '操作成功',
                            });
                            this.ajaxFunction();
                        } else {
                        }
                    }
                });
            },
            handleSizeChange(val) {
                this.pageSize = val;
                this.ajaxFunction();
            },
            handleCurrentChange(val) {
                this.currentPage = val;
                this.ajaxFunction();
            },
            ajaxFunction() {
                this.tableLoading=true;
                $.ajax({
                    url: '/order/billsList.json',
                    type: 'post',
                    data: {
                        orderNo: this.sales_order_no,
                        userName: this.sales_man,
                        startTime: this.startTime,
                        endTime:this.endTime,
                        project_name:this.project_name,
                        page: this.currentPage,
                        size: this.pageSize,
                        type: 23
                    },
                    dataType: 'json',
                    success: (result) => {
                        this.tableLoading=false;
                        if (result.ret) {
                            this.tableData = result.data.list;
                            this.totalRecords = result.data.total;
                        } else {
                            this.$message({
                                message: '列表加载失败，请稍后重试.',
                                type: 'error'
                            });
                        }
                    }
                });
            },
        },

        async mounted() {
            this.ajaxFunction();
        }
    })
</script>
</body>

</html>